public class RemoveElement {
    public int removeElement(int[] nums, int val) {
        int n = nums.length;
        if(n==0){
            return 0;
        }
        int fast = 0, slow = 0;
        while (fast < n) {
            for (int i = 0; i < n; i++) {
                if (nums[fast] != val) {
                    nums[slow]=nums[fast];
                    ++slow;
                }
            }++fast;
        }return slow;
    }
}
